#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright 2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
Build everything for pybdist.

* Build the debian package.
* Build the zip file via setup.py sdist
* Upload to code.google.com
* Update Freshmeat
* Update twitter
* Verifies versions

You'll need:
  sudo ap-get install alien help2man fakeroot cdbs lintian
"""

import sys
sys.path.insert(0, 'src')
from pybdist import pybdist
import setup

def main():
  import optparse
  parser = optparse.OptionParser()
  pybdist.add_standard_options(parser, setup)
  parser.add_option('--all', dest='all', action='store_true',
                    help='Do everything')
  (options, args) = parser.parse_args()

  if pybdist.handle_standard_options(options, setup):
    pass
  elif options.all:
    pybdist.check_for_errors(setup)
    pybdist.build_man(setup)
    pybdist.build_zip_tar(setup)
    pybdist.build_deb(setup)
    pybdist.print_release_info(setup)
    pybdist.upload_to_google_code(setup)
    pybdist.upload_to_py_pi(setup)
    pybdist.announce_on_freshmeat(setup)
    pybdist.announce_on_twitter(setup)
  else:
    print 'Doing nothing.  --help for commands.'

if __name__ == '__main__':
  main()
